#include"Window.h"

Window :: Window(){
	WId = 100;
	StressLvl = 0;
	InfraredLvl = 0;
	IsClose = true;
	SensorStress temp1(WId);
	WinStrssSensor = temp1;
	SensorInfrared temp2(WId);
	WinInfraSensor = temp2;
	SensorOpenClose temp3(WId);
	WinOpClSensor = temp3;
}

Window :: Window(int &_WId, int &_StressLvl, int &_InfraredLvl, bool _IsClose){
	if(_WId >= 100 && _WId < 200){
		WId = _WId;
		StressLvl = _StressLvl;
		InfraredLvl = _InfraredLvl;
		IsClose = _IsClose;
		SensorStress temp1(WId);
		WinStrssSensor = temp1;
		SensorInfrared temp2(WId);
		WinInfraSensor = temp2;
		SensorOpenClose temp3(WId);
		WinOpClSensor = temp3;
	}
	else
		cout<<"The Id of window should between 100 and 200 !"<<endl;
}

void Window :: WindowSimulation(){
	cout<<"Please enter the window's id(must one integer between 100 and 200): ";
	int _WId;
	cin>>_WId;
	cout<<"Please enter the stress level of the window(an integer): ";
	int _StressLvl;
	cin>>_StressLvl;
	cout<<"Please enter the infrared level of the window(an integer): ";
	int _InfraredLvl;
	cin>>_InfraredLvl;
	cout<<"Please enter the state of the window(0 stands for close, 1 stands for open): "
	bool OpenClose;
	cin>>OpenClose;
	cout<<"Please set the parameter of the window's sensors(the first is stresspoint, next is infraredpoint) :";
	int StressPoint, InfraredPoint;
	cin>>StressPoint>>InfraredPoint;
	if(_WId >= 100 && _WId < 200){
		WId = _WId;
		StressLvl = _StressLvl;
		InfraredLvl = _InfraredLvl;
		IsClose = OpenClose;
		SensorStress temp1(WId, StressPoint);
		WinStrssSensor = temp1;
		SensorInfrared temp2(WId, InfraredPoint);
		WinInfraSensor = temp2;
		SensorOpenClose temp3(WId);
		WinOpClSensor = temp3;
	}
	else
		cout<<"The Id of window should between 100 and 200 !"<<endl;
}


void Window :: SetStressLvl(int &_StressLvl){
	StressLvl = _StressLvl;
}

void Window :: SetInfraredLvl(int &_InfraredLvl){
	InfraredLvl = _InfraredLvl;
}

void Window :: CloseWindow(){
	if(IsClose == false)
	IsClose = true;
}

List<Msg> Window :: GetMsg(){
	List<Msg> temp;
	Msg Receive;
	WinStrssSensor.CaptureStress(StressLvl);
	Receive = WinStrssSensor.ReturnMsg();
	if(Receive.MId != ExcptNone) temp.Insert(temp.GetSize(), Receive);
	WinInfraSensor.CaptureInfrared(InfraredLvl);
	Receive = WinInfraSensor.ReturnMsg();
	if(Receive.MId != ExcptNone) temp.Insert(temp.GetSize(), Receive);
	WinOpClSensor.CaptureOpCls(IsClose);
	Receive = WinOpClSensor.ReturnMsg();
	if(Receive.MId != ExcptNone) temp.Insert(temp.GetSize(), Receive);
	return temp;
}

bool Window :: operator ==(const Window &SampleWindow){
	return WId == SampleWindow.WId;
}

bool Window :: operator !=(const Window &SampleWindow){
	return !(WId == SampleWindow.WId);
}